#include "QueueManager.h"
#include "../Core/System.h"
#include "../Shared/Request.h"

QueueManager::QueueManager() : mRequestReceiver(Socket(Protocol_Udp))
{
    mRequestReceiver.Bind(InternetAddress("127.0.0.1" , 4000));
    mRequestReceiver.StartReceiver();
}

QueueManager::~QueueManager()
{
    //dtor
}

void QueueManager::Execute() {
    RawData tReceived;
    InternetAddress tFromAddress;

    while (true) {
        while (!mRequestReceiver.IsReceiverEmpty()) {
            Request tRequest;
            tReceived.Reset();
            mRequestReceiver.ReceiveFrom(tReceived , tFromAddress);
            //TODO: Reply transmission

            tRequest.ReadRawData(tReceived);

            //TODO: Log here!

            push(tRequest);
        }

        System::MilliSleep(500);
    }
}
